#include "widget.h"
#include "ui_widget.h"
#include "galleryitem.h"
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    //初始话数据
    gallerPrivate = new GalleryPrivate();

    QList<GalleryItem * > items;
    //添加8个数据
    GalleryItem *item = new GalleryItem();
    item->setPicture("./image/1.png");
    item->setMessage("从《远方》开启保障音乐环游|宝藏雷达");
    items.append(item);
    //2
    GalleryItem *item2 = new GalleryItem();
    item2->setPicture("./image/2.png");
    item2->setMessage("还在听《隐隐约约》吗|时光雷达");
    items.append(item2);

    GalleryItem *item3 = new GalleryItem();
    item3->setPicture("./image/3.png");
    item3->setMessage("今天从《当爱已成往事》听起|私人雷达");
    items.append(item3);

    GalleryItem *item4 = new GalleryItem();
    item4->setPicture("./image/4.png");
    item4->setMessage("孙楠的歌总是令人心动|时光雷达");
    items.append(item4);

    GalleryItem *item5 = new GalleryItem();
    item5->setPicture("./image/5.png");
    item5->setMessage("吉法师带你来听听歌 |qq雷达");
    items.append(item5);

    GalleryItem *item6 = new GalleryItem();
    item6->setPicture("./image/6.png");
    item6->setMessage("从《爱的代价》开启宝藏音乐|时光雷达");
    items.append(item6);

    GalleryItem *item7 = new GalleryItem();
    item7->setPicture("./image/7.png");
    item7->setMessage("你喜欢的韩国音乐|你的雷达");
    items.append(item7);

    GalleryItem *item8 = new GalleryItem();
    item8->setPicture("./image/8.png");
    item8->setMessage("《The end of word》就是那么好听|时光雷达");
    items.append(item8);

    gallerPrivate->setItemRes(item->width(),item->height(),items);

    ui->horizontalLayout->setContentsMargins(0,0,0,0);
    ui->horizontalLayout->addWidget(gallerPrivate->getItemViewport());

    this->setStyleSheet("QWidget#Widget{border:1px; background:white; border-radius:5px;}");
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    int num = gallerPrivate->getPreviousItemIndex();
    gallerPrivate->showImage(num);
}

void Widget::on_pushButton_2_clicked()
{
    int num =gallerPrivate->getNextItemIndex();
    gallerPrivate->showImage(num);
}
